package com.linshengjian.snowball.finance.entity;

import com.linshengjian.snowball.core.BaseEntity;
import com.linshengjian.snowball.finance.model.Savings;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

@Accessors(chain = true)
@Getter
@Setter
@Entity(name = "savings")
public class SavingsEntity extends BaseEntity<Long, Savings> {
    @Column(nullable = false, columnDefinition = "double default 0")
    private Double surplus = 0d; // 余额
    @Column(nullable = false, columnDefinition = "double default 0")
    private Double expenditure = 0d; // 支出总额
    @Column(nullable = false, columnDefinition = "double default 0")
    private Double income = 0d; // 收入总额
    @OneToMany(mappedBy = "savings")
    @OrderBy("createTime desc")
    private Set<SavingsRecordEntity> records = new HashSet<>();
}
